home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Franz PD / Franz PD Disk #005 (19xx)(Amiga User Group Deutschland e.V.).zip / Franz PD Disk #005 (19xx)(Amiga User Group Deutschland e.V.).adf / Flip / flip.s < prev   
Text File  |  1986-10-22  |  6KB  |  226 lines

  1. *  flip.s
  2. *  5 Apr 87
  3. *
  4. *  Written by Mike Berro of BCS Software
  5. *  (818) 362-6031  CIS: [73267,3361]
  6. *  Based on tilt.c by Leo L. Schwab
  7. *  I hacked this together in 2 hours; C into assembly is no problem!
  8. *  It is slow because of the need to flip individual bits left to right.
  9. *    It'd be a LOT slower in C!  Is there a faster way to do the flip?
  10. *  How about turning the display sideways?
  11. *  You can insert your own effects in the effects subroutine.
  12.  
  13.    INCLUDE "exec/types.i"
  14.    INCLUDE "exec/nodes.i"
  15.    INCLUDE "exec/lists.i"
  16.    INCLUDE "exec/ports.i"
  17.    INCLUDE "exec/libraries.i"
  18.    INCLUDE "exec/tasks.i"
  19.    INCLUDE "intuition/intuition.i"
  20.    INCLUDE "graphics/display.i"
  21.    INCLUDE "graphics/gfxbase.i"
  22.  
  23.    XREF _AbsExecBase
  24.  
  25.    XREF _LVOOpenLibrary          ;intuition
  26.    XREF _LVOCloseLibrary
  27.    XREF _LVOOpenWindow
  28.    XREF _LVOCloseWindow
  29.    XREF _LVOOpenScreen
  30.    XREF _LVOCloseScreen
  31.    XREF _LVOScreenToFront
  32.    XREF _LVOScreenToBack
  33.    XREF _LVODisplayAlert
  34.  
  35.    XREF _LVOBltBitMap            ;graphics
  36.  
  37.    moveq.l  #101,d6              ;d6 is the error flag: 101=can't open Intui
  38.    lea      IntuitionName,a1
  39.    moveq.l  #0,d0
  40.    movea.l  _AbsExecBase,a6
  41.    jsr      _LVOOpenLibrary(a6)
  42.    move.l   d0,IntuitionBase
  43.    beq      all_done
  44.    addq.l   #1,d6                ;102=can't open Graphics Library
  45.    lea      GraphicsName,a1
  46.    moveq.l  #0,d0
  47.    movea.l  _AbsExecBase,a6
  48.    jsr      _LVOOpenLibrary(a6)
  49.    move.l   d0,GraphicsBase
  50.    beq      all_done
  51.  
  52.    addq.l   #1,d6                ;103=can't open window
  53.    lea      MyNewWindow,a0
  54.    movea.l  IntuitionBase,a6
  55.    jsr      _LVOOpenWindow(a6)
  56.    move.l   d0,MyWindow
  57.    beq      all_done
  58.  
  59.    addq.l   #1,d6                      ;104=can't open screen
  60.    move.l   MyWindow,a0
  61.    move.l   wd_WScreen(a0),a1          ;a1 points to WBench screen
  62.    move.l   sc_RastPort+rp_BitMap(a1),wbm  ;points to Workbench BitMap structure
  63.    lea      MyNewScreen,a0
  64.    move.w   sc_LeftEdge(a1),ns_LeftEdge(a0)
  65.    move.w   sc_TopEdge(a1),ns_TopEdge(a0)
  66.    moveq.l  #0,d4
  67.    move.w   sc_Width(a1),d4            ;save for BltBitMap
  68.    move.w   d4,ns_Width(a0)
  69.    moveq.l  #0,d5
  70.    move.w   sc_Height(a1),d5           ;save for BltBitMap
  71.    move.w   d5,ns_Height(a0)
  72.    move.w   sc_ViewPort+vp_Modes(a1),ns_ViewModes(a0)
  73.    jsr      _LVOOpenScreen(a6)
  74.    move.l   d0,MyScreen
  75.    beq      all_done
  76.  
  77.    move.l   d0,a0
  78.    jsr      _LVOScreenToBack(a6)
  79.  
  80.    move.l   MyScreen,a1
  81.    move.l   sc_RastPort+rp_BitMap(a1),a1  ;my BitMap
  82.    move.l   a1,a2
  83.    adda.l   #bm_Planes,a2
  84.    move.l   (a2)+,Plane1            ;points to actual video memory
  85.    move.l   (a2)+,Plane2
  86.    move.l   wbm,a0                  ;WB's BitMap
  87.    moveq.l  #0,d0                   ;faster than clr.l
  88.    moveq.l  #0,d1
  89.    moveq.l  #0,d2
  90.    moveq.l  #0,d3
  91.    move.l   #$c0,d6
  92.    move.l   #$ff,d7
  93.    move.l   #0,a2
  94.    movea.l  GraphicsBase,a6
  95.    jsr      _LVOBltBitMap(a6)       ;copy WB onto my custom screen
  96.  
  97.    movea.l  Plane1,a0
  98.    bsr      do_flip              ;do the effect on plane1
  99.    movea.l  Plane2,a0
  100.    bsr      do_flip              ;and on plane 2
  101.  
  102.    movea.l  MyScreen,a0
  103.    movea.l  IntuitionBase,a6
  104.    jsr      _LVOScreenToFront(a6)      ;show it
  105.  
  106.    move.l  #800000,d0
  107. lp_delay:
  108.    subq.l   #1,d0
  109.    bne.s    lp_delay
  110.  
  111.    move.l   #RECOVERY_ALERT,d0
  112.    lea      message,a0
  113.    moveq.l  #30,d1
  114.    jsr      _LVODisplayAlert(a6)       ;pseudo-guru
  115.  
  116.    moveq.l  #0,d6                   ;no error
  117.  
  118. all_done:
  119.    movea.l  IntuitionBase,a6
  120.    tst.l    MyScreen
  121.    beq.s    2$
  122.    movea.l  MyScreen,a0
  123.    jsr      _LVOCloseScreen(a6)
  124. 2$:
  125.    tst.l    MyWindow
  126.    beq.s    3$
  127.    movea.l  MyWindow,a0
  128.    jsr      _LVOCloseWindow(a6)
  129. 3$:
  130.    move.l   _AbsExecBase,a6
  131.    tst.l    GraphicsBase
  132.    beq.s    4$
  133.    move.l   GraphicsBase,a1
  134.    jsr      _LVOCloseLibrary(a6)
  135. 4$:
  136.    tst.l    IntuitionBase
  137.    beq.s    5$
  138.    move.l   IntuitionBase,a1
  139.    jsr      _LVOCloseLibrary(a6)
  140. 5$:
  141.    move.l   d6,d0
  142.    rts
  143.  
  144. **************** Effects subroutine
  145.  
  146. do_flip:
  147.    move.l   a0,a1
  148.    add.l    #16000,a1
  149.    move.l   #100,d0           ;# lines
  150. lp_flip1:
  151.    move.l   #20,d1            ;# long words per line
  152. lp_flip2:
  153.    move.l   (a0),d2
  154.    bsr      sideflip
  155.    move.l   -(a1),d2
  156.    move.l   d5,(a1)
  157.    bsr      sideflip
  158.    move.l   d5,(a0)+
  159.    subq.l   #1,d1
  160.    bne.s    lp_flip2
  161.    subq.l   #1,d0
  162.    bne.s    lp_flip1
  163.    rts
  164.  
  165. sideflip:
  166.    moveq.l  #0,d5             ;clear the target
  167.    moveq.l  #31,d3            ;source bit number index
  168.    moveq.l  #0,d4             ;target "   "      "
  169. lp_sideflip:
  170.    btst.l   d3,d2
  171.    beq.s    1$
  172.    bset.l   d4,d5
  173. 1$:
  174.    addq.l   #1,d4
  175.    subq.l   #1,d3
  176.    bpl.s    lp_sideflip
  177.    rts
  178.  
  179.    SECTION fdata,DATA
  180.  
  181. IntuitionBase: dc.l  0
  182. GraphicsBase:  dc.l  0
  183.  
  184. MyWindow:      dc.l  0
  185. MyScreen:      dc.l  0
  186. wbm:           dc.l  0
  187. Plane1:        dc.l  0
  188. Plane2:        dc.l  0
  189.  
  190. **************** Screen data
  191.  
  192. MyNewScreen:  dc.w 0,0,0,0   ;size filled in later
  193.               dc.w 2      ;depth
  194.               dc.b 0,1
  195.               dc.w 0      ;viewmodes filled in later
  196.               dc.w CUSTOMSCREEN
  197.               dc.l 0
  198.               dc.l 0      ;screen title
  199.               dc.l 0,0
  200.  
  201. **************** Window data
  202.  
  203. MyFlags       EQU SMART_REFRESH!ACTIVATE!WINDOWDEPTH!WINDOWDRAG
  204. MyNewWindow:  dc.w 0,30,100,10
  205.               dc.b -1,-1
  206.               dc.l 0
  207.               dc.l MyFlags
  208.               dc.l 0,0
  209.               dc.l MyTitle
  210.               dc.l 0,0
  211.               dc.w 0,0,0,0
  212.               dc.w WBENCHSCREEN
  213.  
  214. MyTitle:
  215.    dc.b  'Flip',0
  216. IntuitionName:
  217.    dc.b  'intuition.library',0
  218. GraphicsName:
  219.    dc.b  'graphics.library',0
  220. message:
  221.    dc.b  1,34,22
  222.    dc.b  'Flipped Out!',0
  223.  
  224.    END
  225.  
  226.